package com.ihg.hiex.entity.session.during;

import java.beans.Transient;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;

import com.demo2do.core.utils.DateFormatUtils;
import com.ihg.hiex.entity.session.participator.Type;
import com.ihg.hiex.entity.session.task.SessionTaskType;

/**
 * During 状态会议及打分时间模板
 * @author dan
 *
 */
@Entity
@Table(name = "session_scheduling_template")
public class SessionSchedulingTemplate {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 名称 */
    private String name;
    
    /** 第几天 */
    private int day;
    
    /** 开始时间 HH:mm */
    private String startTime;
    
    /** 结束时间 HH:mm */
    private String endTime;
    
    /** group中assessor排位 */
    private String assessor;
    
    /** group中delegate排位 */
    private String delegate;
    
    /** 参与者 */
    @Enumerated(EnumType.STRING)
    private Type target;
    
    /** 父 task */
    private String parent;
    
    /** 类型 -- 会议or其他 */
    @Enumerated(EnumType.STRING)
    private SessionTaskType type;
    
    /** 分钟数 */
    private int minutes;
    
    /** 是否大组 */
    @Column(name = "is_group")
    private boolean group;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public SessionSchedulingTemplate() {
        
    }
    
    /**
     * 
     * @param sessionDate
     * @return
     */
    @Transient
    public Date getStartDate(Date sessionDate) {
        Date startDate = com.demo2do.core.utils.DateUtils.parseDate(DateFormatUtils.format(DateUtils.addDays(sessionDate, day), "yyyy-MM-dd ") + startTime, "yyyy-MM-dd HH:mm");
        return startDate;
    }
    
    /**
     * 
     * @param sessionDate
     * @return
     */
    @Transient
    public Date getEndDate(Date sessionDate) {
        Date endDate = com.demo2do.core.utils.DateUtils.parseDate(DateFormatUtils.format(DateUtils.addDays(sessionDate, day), "yyyy-MM-dd ") + endTime, "yyyy-MM-dd HH:mm");
        return endDate;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public boolean isOnlyAssessor() {
        return StringUtils.isNoneBlank(this.assessor) && StringUtils.isBlank(this.delegate);
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public boolean isOnlyDelegate() {
        return StringUtils.isBlank(this.assessor) && StringUtils.isNoneBlank(this.delegate);
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the day
     */
    public int getDay() {
        return day;
    }

    /**
     * @return the startTime
     */
    public String getStartTime() {
        return startTime;
    }

    /**
     * @return the endTime
     */
    public String getEndTime() {
        return endTime;
    }

    /**
     * @return the assessor
     */
    public String getAssessor() {
        return assessor;
    }

    /**
     * @return the delegate
     */
    public String getDelegate() {
        return delegate;
    }

    /**
     * @return the target
     */
    public Type getTarget() {
        return target;
    }

    /**
     * @return the parent
     */
    public String getParent() {
        return parent;
    }

    /**
     * @return the type
     */
    public SessionTaskType getType() {
        return type;
    }

    /**
     * @return the minutes
     */
    public int getMinutes() {
        return minutes;
    }

    /**
     * @return the group
     */
    public boolean isGroup() {
        return group;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param day the day to set
     */
    public void setDay(int day) {
        this.day = day;
    }

    /**
     * @param startTime the startTime to set
     */
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    /**
     * @param endTime the endTime to set
     */
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    /**
     * @param assessor the assessor to set
     */
    public void setAssessor(String assessor) {
        this.assessor = assessor;
    }

    /**
     * @param delegate the delegate to set
     */
    public void setDelegate(String delegate) {
        this.delegate = delegate;
    }

    /**
     * @param target the target to set
     */
    public void setTarget(Type target) {
        this.target = target;
    }

    /**
     * @param parent the parent to set
     */
    public void setParent(String parent) {
        this.parent = parent;
    }

    /**
     * @param type the type to set
     */
    public void setType(SessionTaskType type) {
        this.type = type;
    }

    /**
     * @param minutes the minutes to set
     */
    public void setMinutes(int minutes) {
        this.minutes = minutes;
    }

    /**
     * @param group the group to set
     */
    public void setGroup(boolean group) {
        this.group = group;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
